package com.example.ywr.repository;

import com.example.ywr.entity.OrderItem;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 订单项数据访问层
 */
@Repository
public interface OrderItemRepository extends JpaRepository<OrderItem, Long> {

    /**
     * 根据订单ID查询订单项
     */
    List<OrderItem> findByOrderIdAndIsDeletedFalse(Long orderId);

    /**
     * 根据订单编号查询订单项
     */
    List<OrderItem> findByOrderNoAndIsDeletedFalse(String orderNo);

    /**
     * 根据商品ID查询订单项
     */
    List<OrderItem> findByProductIdAndIsDeletedFalse(Long productId);
}